 
<%@page import="doantotnghiep.modelDTO.ProviderDTO"%>
<%@page import="java.util.HashMap"%>
<%@page import="doantotnghiep.modelDTO.CategoryDTO"%>
<%@page import="doantotnghiep.modelDTO.MeasureUnitDTO"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page import="doantotnghiep.model.Customer"%>
<%@taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@page import="java.util.ArrayList"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Thêm dược phẩm</title>
</head>
<body>
  <% HashMap<String, Object> medicamentModel = (HashMap<String, Object>) request.getAttribute("medicamentModel");
 		%>	
<br>
<br>
<div>
	<center>
		<h1 style="color: blue;">THÊM DƯỢC PHẨM</h1>
		<br> <br>

		<!-- In dòng thông báo là thành công hay không -->
		<p style="color: green; font-size: 15px; font-weight: bold;">
		</p>

		<br>

		<!-- form nhập dữ liệu -->

		<div align="center">

       <form:form method="POST" commandName="MedicamentDTO" >
		<table>
			<tr>
				<td><form:label path="medicamentName">Tên dược phẩm:</form:label></td>
				<td><form:input id="medicamentName" path="medicamentName"></form:input></td>
				<td><span id="medicinename-error" style="color:red"> </span></td>
			</tr>
			<tr>
				<td><form:label path="measure_ID">Mã đơn vị tính:</form:label></td>
				 <td><form:select path="measure_ID" value="${measure_ID}">
			           <%
			            if(medicamentModel!=null){
   					    	 ArrayList<MeasureUnitDTO> measureUnitDTOs = (ArrayList<MeasureUnitDTO>) medicamentModel.get("measures");
   					   		 if(measureUnitDTOs!=null){ 
   					         	for (int i = 0; i < measureUnitDTOs.size(); i++) {			 
						   	 %>
				            <option value="<%=measureUnitDTOs.get(i).getId()%>"><%=measureUnitDTOs.get(i).getUnitName()%></option>
				           <%}}}%>
						</form:select></td>
					</tr>
            <tr>
				<td><form:label path="category_ID">Mã nhóm sản phẩm:</form:label></td>
				 <td><form:select path="category_ID" value="${category_ID}">
			           <%
			            if(medicamentModel!=null){
   					    	 ArrayList<CategoryDTO> categoryDTOs =(ArrayList<CategoryDTO>) medicamentModel.get("categories");
   					   		 if(categoryDTOs!=null){ 
   					         	for (int i = 0; i < categoryDTOs.size(); i++) {			 
						   	 %>
				            <option value="<%=categoryDTOs.get(i).getId()%>"><%=categoryDTOs.get(i).getCategoryName()%></option>
				           <%}}}%>
						</form:select></td>
					</tr>
			<tr>
				<td><form:label path="provider_ID">Nhà cung cấp:</form:label></td>
				 <td><form:select path="provider_ID" value="${provider_ID}">
			           <%
			            if(medicamentModel!=null){
   					    	 ArrayList<ProviderDTO> providerDTOs  = (ArrayList<ProviderDTO>) medicamentModel.get("providers");
   					   		 if(providerDTOs!=null){ 
   					         	for (int i = 0; i < providerDTOs.size(); i++) {			 
						   	 %>
				            <option value="<%=providerDTOs.get(i).getId()%>"><%=providerDTOs.get(i).getFullName()%></option>
				           <%}}}%>
						</form:select></td>
					</tr>
			 <tr>
				<td><form:label path="boughtPrice">Đơn giá nhập:</form:label></td>
				<td><form:input id="boughtPrice" path="boughtPrice"  /></td>	
				<td><span id="medicinebought-error" style="color:red"> </span></td>
			</tr>
			 <tr>
				<td><form:label path="sellPrice">Đơn giá bán:</form:label></td>
				<td><form:input id="sellPrice" path="sellPrice"  /></td>
				<td><span id="medicinesell-error" style="color:red"> </span></td>	
			</tr>
			<tr>
				<td ><input id= "addmedicamentsubmit" type="button" value="Thêm" /></td>
				<td ><input id="addmedicamentcancel" type="button" value="Hủy" /></td>
			</tr>
		 </table>
	     </form:form>

		</div>


	</center>
</div>
<br>
<br>
<br>
<br>
<br>
<br>
</body>
</html>
